/*
 * @Author: CodeHare
 * @Date: 2023-10-30 10:51:56
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-23 14:32:59
 * @Description: EMS参数设置之系统设置
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yt_devops/resources/str_res_keys.dart';

import 'converter_set_model.dart';

class SystemEnableSetModel {
  final gridParamsController1 = TextEditingController();
  final gridParamsController2 = TextEditingController();

  /// 系统使能设置列表
  List<EnableItemModel> get systemEnableSetList => [
        EnableItemModel(
            ResKey.deviceSystemEnablingSettings.tr,
            ResKey.deviceParameterSetting.tr,
            ResKey.deviceParameterSetting.tr), // "系统使能设置"
        EnableItemModel(
            ResKey.deviceSelfStartFunctionEnabled.tr, "", ""), // 自启动功能使能
        EnableItemModel(
            ResKey.deviceMainsChargeFunctionEnables.tr, "", ""), // 市电充电功能使能
        EnableItemModel(
            ResKey.deviceEnablingFffGridWorkFunction.tr, "", ""), // 离网工作功能使能
        EnableItemModel(
            ResKey.deviceEnablingGridConnectionFunction.tr, "", ""), // 并网工作功能使能
      ].toList();

  set systemEnableSetList(List<EnableItemModel> updateList) {
    systemEnableSetList = updateList;
  }

  /// 系统校时设置列表

  List<EnableItemModel> get systemTimingSetList => [
        EnableItemModel(
            ResKey.deviceTimeSetting.tr,
            ResKey.deviceParameterSetting.tr,
            ResKey.deviceParameterSetting.tr), // "系统校时设置",
        EnableItemModel('common.systemTime'.tr, "", ""), // 系统时间
      ].toList();

  set systemTimingSetList(List<EnableItemModel> updateList) {
    systemEnableSetList = updateList;
  }

  /// 电网参数设置列表
  List<GridParameterItem> get gridParamsSettingList => [
        GridParameterItem(ResKey.deviceGridParameterSetting.tr, "",
            ResKey.deviceParameterSetting.tr, null), // 电网参数设置
        GridParameterItem(ResKey.deviceAntiBackflowThreshold.tr, "kW", "",
            gridParamsController1), // 防逆流阈值
        GridParameterItem(ResKey.deviceMaximumLoadOfTransformer.tr, "kW", "",
            gridParamsController2), // 变压器最大功率
      ].toList();

  set gridParamsSettingList(List<GridParameterItem> updateList) {
    gridParamsSettingList = updateList;
  }

  SystemEnableSetModel();
}

class EnableItemModel {
  String label;
  String previousValue;
  String value;

  EnableItemModel(
    this.label,
    this.previousValue,
    this.value,
  );
}

class GridParameterItem {
  String label;
  String unit;
  String value;
  TextEditingController? textEditingController;

  GridParameterItem(
    this.label,
    this.unit,
    this.value,
    this.textEditingController,
  );
}
